package com.sg.service.biz.bff.impl;

import com.sg.common.util.CommonFunctionHelper;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.bff.req.BffObtainExecuteProgressComBorderReqDto;
import com.sg.dto.biz.bff.req.BffResetExecuteProgressDisposeComReqDto;
import com.sg.dto.biz.bff.res.BffObtainExecuteProgressComBorderRespDto;
import com.sg.dto.biz.bff.res.BffResetExecuteProgressDisposeComRespDto;
import com.sg.dto.integration.app.QueryStepExecuteProgressDetailReqDto;
import com.sg.dto.integration.app.QueryStepExecuteProgressDetailRespDto;
import com.sg.dto.integration.app.ResetExecuteProgressDisposeComReqDto;
import com.sg.dto.integration.app.ResetExecuteProgressDisposeComRespDto;
import com.sg.service.biz.bff.ExecuteProgressService;
import com.wicket.okrapp.integration.ExecuteProgressService;
import com.sg.common.exception.Assert;
import com.wicket.okrcomponent.integration.InterfaceModeService;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class ExecuteProgressServiceImpl implements ExecuteProgressService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    com.sg.service.biz.app.ExecuteProgressService fwAppExecuteProgressClient;
    @Resource
    com.sg.service.biz.component.InterfaceModeService fwCompInterfaceModeClient;

    /**
     * B3获取执行进度情况(公共)[6975]
     * gen by moon at 1/18/2024, 7:21:23 PM
     */
    @Trace(operationName = "B3获取执行进度情况(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffObtainExecuteProgressComBorderRespDto obtainExecuteProgressComBorder(BffObtainExecuteProgressComBorderReqDto reqDto) {


        QueryStepExecuteProgressDetailRespDto queryStepExecuteProgressDetailRespDto_1 = null;
//步骤0: D3查步骤执行进度情况 - queryStepExecuteProgressDetail
        QueryStepExecuteProgressDetailRespDto queryStepExecuteProgressDetailRespDto = null;
        QueryStepExecuteProgressDetailReqDto queryStepExecuteProgressDetailReqDto = new QueryStepExecuteProgressDetailReqDto();
        if (reqDto != null) {
            queryStepExecuteProgressDetailReqDto.setObjectId(reqDto.getObjectId());//SimpleFieldAssign//sourceId:987855_1
            queryStepExecuteProgressDetailReqDto.setUseTypeCode(reqDto.getUseTypeCode());//SimpleFieldAssign//sourceId:987856_1
            queryStepExecuteProgressDetailReqDto.setThemeContentId(reqDto.getThemeContentId());//SimpleFieldAssign//sourceId:987857_1
            queryStepExecuteProgressDetailReqDto.setConfItemCode(reqDto.getConfItemCode());//SimpleFieldAssign//sourceId:1071147_1
            queryStepExecuteProgressDetailReqDto.setCustomField(reqDto.getCustomField());//SimpleFieldAssign//sourceId:987861_1
        }

        /*D3查步骤执行进度情况[6966]   */
        Assert.isNull(queryStepExecuteProgressDetailReqDto.getObjectId(), "B3获取执行进度情况(公共)-D3查步骤执行进度情况-归属对象内容ID不能为空", false);
        Assert.isNull(queryStepExecuteProgressDetailReqDto.getUseTypeCode(), "B3获取执行进度情况(公共)-D3查步骤执行进度情况-用途类型编码不能为空", false);
        Assert.isNull(queryStepExecuteProgressDetailReqDto.getThemeContentId(), "B3获取执行进度情况(公共)-D3查步骤执行进度情况-主题内容ID不能为空", false);
        Assert.isNull(queryStepExecuteProgressDetailReqDto.getConfItemCode(), "B3获取执行进度情况(公共)-D3查步骤执行进度情况-配置项标识不能为空", false);
        Assert.isNull(queryStepExecuteProgressDetailReqDto.getCustomField(), "B3获取执行进度情况(公共)-D3查步骤执行进度情况-是否精准进度查询背景图不能为空", false);
        queryStepExecuteProgressDetailRespDto = fwAppExecuteProgressClient.queryStepExecuteProgressDetail(queryStepExecuteProgressDetailReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        queryStepExecuteProgressDetailRespDto_1 = queryStepExecuteProgressDetailRespDto;

        BffObtainExecuteProgressComBorderRespDto retData = new BffObtainExecuteProgressComBorderRespDto();
        if (queryStepExecuteProgressDetailRespDto_1 != null) {
            retData.setExecuteProgressValue(queryStepExecuteProgressDetailRespDto_1.getExecuteProgressValue());//SimpleFieldAssign//sourceId:1080359_1
            retData.setExtensionField3(queryStepExecuteProgressDetailRespDto_1.getExtensionField3());//SimpleFieldAssign//sourceId:1066416_1
            // TODO: 2024/1/18
            retData.setBackGroundAddress(CommonFunctionHelper.getFilePath(queryStepExecuteProgressDetailRespDto_1.getBackGroundAddress()));//SimpleFieldAssign//sourceId:1490372_1
        }


        return retData;
    }

    /**
     * B3重置执行进度处理(公共)[7211]
     * gen by moon at 6/28/2023, 7:03:31 PM
     */
    @Trace(operationName = "B3重置执行进度处理(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffResetExecuteProgressDisposeComRespDto resetExecuteProgressDisposeCom(BffResetExecuteProgressDisposeComReqDto reqDto) {


        //步骤0: D3-重置执行进度处理(公共) - resetExecuteProgressDisposeCom
        ResetExecuteProgressDisposeComRespDto resetExecuteProgressDisposeComRespDto = null;
        ResetExecuteProgressDisposeComReqDto resetExecuteProgressDisposeComReqDto = new ResetExecuteProgressDisposeComReqDto();
        if (reqDto != null) {
            resetExecuteProgressDisposeComReqDto.setObjectId(reqDto.getObjectId());//SimpleFieldAssign//sourceId:1037654_1
            resetExecuteProgressDisposeComReqDto.setUseTypeCode(reqDto.getUseTypeCode());//SimpleFieldAssign//sourceId:1037655_1
            resetExecuteProgressDisposeComReqDto.setThemeContentId(reqDto.getThemeContentId());//SimpleFieldAssign//sourceId:1037656_1
        }

        /*D3-重置执行进度处理(公共)[7210]   */
        Assert.isNull(resetExecuteProgressDisposeComReqDto.getObjectId(), "B3重置执行进度处理(公共)-D3-重置执行进度处理(公共)-归属对象内容ID不能为空", false);
        Assert.isNull(resetExecuteProgressDisposeComReqDto.getUseTypeCode(), "B3重置执行进度处理(公共)-D3-重置执行进度处理(公共)-用途类型编码不能为空", false);
        Assert.isNull(resetExecuteProgressDisposeComReqDto.getThemeContentId(), "B3重置执行进度处理(公共)-D3-重置执行进度处理(公共)-主题内容ID不能为空", false);
        resetExecuteProgressDisposeComRespDto = fwAppExecuteProgressClient.resetExecuteProgressDisposeCom(resetExecuteProgressDisposeComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        BffResetExecuteProgressDisposeComRespDto retData = new BffResetExecuteProgressDisposeComRespDto();


        return retData;
    }
    //
}
